<#include "/common/head.html"/>

<#-- 计算table列数 -->
<#assign columnSize=head.dialog_size?split("x")[0]?number />
<#if columnSize lt 700>
	<#assign columnSize=1 />
<#else>
	<#assign columnSize=2 />
</#if>

 <div class="easyui-panel updatePage<#if columnSize gt 1> multiple</#if>" data-options="fit:true,border:false">
    <form id="ff" class="easyui-form" method="post">
        <table class="table1">
       	<#list updateFieldList as item>
           	<#if item_index == 0 || item_index % columnSize == 0>
            <tr>
           	</#if>
           		<th><span>${item.column_name}：</span></th>
               	<td>
            <#if item.is_allow_update == 1>
               	<#if item.input_type == 'easyui-combobox'>
               		<div class="wrap_input"><input id="${item.field_name}" name="${item.field_name}" id="${item.field_name}" class="easyui-combobox" value="${model[item.field_name]!''}" data-options="
               				<#if item.is_allow_null==0>required:true,</#if>
               				valueField: 'id',
        					textField: 'text',
        					fit: true,
        					data:[
        						{id:'', text:''}<#list item.dict.keySet() as key>,{id:'${key}', text:'${item.dict.get(key)}'}</#list>
	               			]
               		"/></div>
               	<#elseif item.input_type == 'easyui-filebox_img'>	
			        <div class="wrap_input"><input class="easyui-filebox" type="text" name="${item.field_name}" id="${item.field_name}" value="${model[item.field_name]!''}" data="${model[item.field_name]!''}" data-options="fit: true<#if item.is_allow_null==0>,required:true</#if>,buttonText: '选择图片', accept1: 'image/*', onChange: function(){uploadFile('${item.field_name}')}"></input></div>
					<div class="image_pre" <#if model[item.field_name]??>style="display: block;"</#if>><img id="${item.field_name}Img" src="${basePath}${model[item.field_name]!''}"></div>
               	<#elseif item.input_type == 'textarea'>	
               		<div class="wrap_input textarea"><textarea name="${item.field_name}" id="${item.field_name}" rows="5" class="easyui-validatebox" data-options="<#if item.is_allow_null==0>required:true</#if>">${model[item.field_name]!''}</textarea></div>
               	<#else>
               		<div class="wrap_input"><input class="${item.input_type}" type="text" name="${item.field_name}" id="${item.field_name}" value="${model[item.field_name]!''}" data-options="fit: true<#if item.is_allow_null==0>,required:true</#if>"></input></div>
               	</#if>
             <#else>
               		<#escape x as x?html><#-- 安全输出 -->
               		<span class="item" id="${item.field_name}">${model[item.field_name]!''}</span>
               		</#escape>
             </#if>	
           		</td>
           		
           	<#if item_index != 0 && (item_index + 1) % columnSize == 0>
            </tr>
           	</#if>
         </#list>
         <#if updateFieldList.size() % columnSize != 0>
           	<#if (columnSize - updateFieldList.size() % columnSize) == 1>
                <td colspan="2"></td>
	        </#if>
	        <#if (columnSize - updateFieldList.size() % columnSize) == 2>
                <td colspan="2"></td>
                <td colspan="2"></td>
	        </#if>
            </tr>
        </#if>
        </table>
    </form>
</div>
<script>
top.window.subPage.save = save;
function save() {
	if($("#zcurdHeadTable").form('validate')) {
		$.post("update", getParam(), function(data) {
			top.window.closeWindow();
			top.window.subPage.loadCurrDatagrid();
		});
	}
}
function getParam() {
	var param = {
	    "headId": ${headId}, 
	    "id": ${model[head.id_field]}, 
		<#list updateFieldList as item><#if item.is_allow_update == 1>
       	    "model.${item.field_name}": getInputValue("${item.field_name}")<#if updateFieldList.size()!=item_index>, </#if>
		</#if></#list>
	}
	for(key in param) {
		if(!param[key]) {
			delete param[key];
		}
	}
	return param;
}

//扩展js
<#list jsList as item>
	<#if item.page?contains("update")>
${item.js_content!}
	</#if>
</#list>
</script>
<#include "/common/foot.html"/>